﻿using ACompany.OrderProcessing.NHibernateRepository;
using ACompany.OrderProcessing.Infrastructure;
using ACompany.OrderProcessing.Services;
using ACompany.OrderProcessing.Model;
using StructureMap;

public class BootStrapper
{
    public static void ConfigureStructureMap()
    {
        ObjectFactory.Initialize(ConfigStructureMap);
    }

    private static void ConfigStructureMap(IInitializationExpression x)
    {
        x.AddRegistry(new ServiceRegistry());
    }

    public class ServiceRegistry : StructureMap.Configuration.DSL.Registry
    {
        protected override void configure()
        {
            ForRequestedType<IProductRepository>().TheDefaultIsConcreteType<ProductRepository>();

            ForRequestedType<IOrderRepository>().TheDefaultIsConcreteType<OrderRepository>();

            ForRequestedType<ICustomerRepository>().TheDefaultIsConcreteType<CustomerRepository>();

            ForRequestedType<ICustomerService>().TheDefaultIsConcreteType<CustomerService>();

            ForRequestedType<IProductService>().TheDefaultIsConcreteType<ProductService>();

            ForRequestedType<IOrderService>().TheDefaultIsConcreteType<OrderService>();

            ForRequestedType<IUnitOfWork>().TheDefaultIsConcreteType<NHibernateUnitOfWork>();
        }
    }
}